import Flutter
import UIKit

public class SwiftFlutterBaichuanPlugin: NSObject, FlutterPlugin {
    var alibchandler: FlutterBaichuanHandle?
    public static func register(with registrar: FlutterPluginRegistrar) {
        let channel = FlutterMethodChannel(name: "flutter_baichuan", binaryMessenger: registrar.messenger())
        let instance = SwiftFlutterBaichuanPlugin()
        instance.alibchandler = FlutterBaichuanHandle(channel: channel)

        registrar.addMethodCallDelegate(instance, channel: channel)
    }

    public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
        if call.method == "getPlatformVersion" {
            result("getPlatformVersion")
        } else if call.method == "initAlibc" {
            alibchandler?.initAlibc(call: call, result: result)
        } else if call.method == "loginTaoBao" {
            alibchandler?.loginTaoBao(call, result: result)
        } else if call.method == "getAccessToken" {
            alibchandler?.getAccessToken(call, result: result)
        } else if call.method == "loginOut" {
            alibchandler?.loginOut(call, result: result)
        } else if call.method == "openByCode" {
            alibchandler?.openByCode(call, result: result)
        } else if call.method == "openByUrl" {
            alibchandler?.openByUrl(call, result: result)
        } else if call.method == "isLogin" {
            alibchandler?.isLogin(call, result: result)
        }else if call.method == "getUtdid" {
            alibchandler?.getUtdid(call, result: result)
        } else {
            result(FlutterMethodNotImplemented)
        }
    }
}
